package com.apartment.own.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.apartment.common.annotation.Log;
import com.apartment.common.core.controller.BaseController;
import com.apartment.common.core.domain.AjaxResult;
import com.apartment.common.enums.BusinessType;
import com.apartment.own.domain.OwnResHouseRoomConf;
import com.apartment.own.service.IOwnResHouseRoomConfService;
import com.apartment.common.utils.poi.ExcelUtil;
import com.apartment.common.core.page.TableDataInfo;

/**
 * 房间配置Controller
 * 
 * @author @Dog_E
 * @date 2020-08-28
 */
@RestController
@RequestMapping("/own/conf")
public class OwnResHouseRoomConfController extends BaseController
{
    @Autowired
    private IOwnResHouseRoomConfService ownResHouseRoomConfService;

    /**
     * 查询房间配置列表
     */
    @PreAuthorize("@ss.hasPermi('own:conf:list')")
    @GetMapping("/list")
    public TableDataInfo list(OwnResHouseRoomConf ownResHouseRoomConf)
    {
        startPage();
        List<OwnResHouseRoomConf> list = ownResHouseRoomConfService.selectOwnResHouseRoomConfList(ownResHouseRoomConf);
        return getDataTable(list);
    }

    /**
     * 导出房间配置列表
     */
    @PreAuthorize("@ss.hasPermi('own:conf:export')")
    @Log(title = "房间配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OwnResHouseRoomConf ownResHouseRoomConf)
    {
        List<OwnResHouseRoomConf> list = ownResHouseRoomConfService.selectOwnResHouseRoomConfList(ownResHouseRoomConf);
        ExcelUtil<OwnResHouseRoomConf> util = new ExcelUtil<OwnResHouseRoomConf>(OwnResHouseRoomConf.class);
        return util.exportExcel(list, "conf");
    }

    /**
     * 获取房间配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('own:conf:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ownResHouseRoomConfService.selectOwnResHouseRoomConfById(id));
    }

    /**
     * 新增房间配置
     */
    @PreAuthorize("@ss.hasPermi('own:conf:add')")
    @Log(title = "房间配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OwnResHouseRoomConf ownResHouseRoomConf)
    {
        return toAjax(ownResHouseRoomConfService.insertOwnResHouseRoomConf(ownResHouseRoomConf));
    }

    /**
     * 修改房间配置
     */
    @PreAuthorize("@ss.hasPermi('own:conf:edit')")
    @Log(title = "房间配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OwnResHouseRoomConf ownResHouseRoomConf)
    {
        return toAjax(ownResHouseRoomConfService.updateOwnResHouseRoomConf(ownResHouseRoomConf));
    }

    /**
     * 删除房间配置
     */
    @PreAuthorize("@ss.hasPermi('own:conf:remove')")
    @Log(title = "房间配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ownResHouseRoomConfService.deleteOwnResHouseRoomConfByIds(ids));
    }
}
